﻿using System;

namespace RFC.AOP
{
    public class ApectContext
    {
        /// <summary>
        /// 设置关联对象
        /// </summary>
        /// <param name="correlationObject"></param>
        public void SetCorrelationObject(object correlationObject)
        {
            CorrelationObject = correlationObject;
        }

        /// <summary>
        /// 设置方法名，Apect生成器内部会调用
        /// </summary>
        /// <param name="methodName"></param>
        public void SetMethodName(string methodName)
        {
            MethodName = methodName;
        }

        /// <summary>
        /// 设置方法执行返回对象，Apect生成器内部会调用
        /// </summary>
        /// <param name="returnObject"></param>
        public void SetReturnObject(object returnObject)
        {
            ReturnObject = returnObject;
#if DEBUG
            Console.WriteLine($"有返回值：{ReturnObject}");
#endif
        }

        /// <summary>
        /// 设置参数，Apect生成器内部会调用
        /// </summary>
        /// <param name="parameters"></param>
        public void SetParameters(object[] parameters)
        {
            Parameters = parameters;
        }

        /// <summary>
        /// 设置执行者，Apect生成器内部会调用
        /// </summary>
        /// <param name="executor"></param>
        public void SetExecutor(object executor)
        {
            Executor = executor;
        }

        /// <summary>
        /// 执行者
        /// </summary>
        public object Executor { get; private set; }

        /// <summary>
        /// 方法名
        /// </summary>
        public string MethodName { get; private set; }

        /// <summary>
        /// 关联参数
        /// </summary>
        public object CorrelationObject { get; private set; }

        /// <summary>
        /// 返回对象
        /// </summary>
        public object ReturnObject { get; private set; }

        /// <summary>
        /// 传参
        /// </summary>
        public object[] Parameters { get; private set; }
    }
}
